package com.xyoto.community.vo;

import com.xyoto.community.constant.ReadStatus;
import com.xyoto.community.utils.PictureUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

/**
 * 私信列表Vo
 */
@Data
@ApiModel("私信列表Vo")
public class PrivateLetterVo {

    @ApiModelProperty("私信列表id")
    private Integer privateLetterListId;

    @ApiModelProperty("朋友id")
    private Integer targetUserId;

    @ApiModelProperty("头像地址")
    private String avatarUrl;

    @ApiModelProperty("昵称")
    private String nickName;

    @ApiModelProperty("阅读状态")
    private Short readStatus;

    @ApiModelProperty("未读私信条数")
    private Integer count;

    @ApiModelProperty("私信内容")
    private String content;

    @ApiModelProperty("图片地址")
    private String path;

    @ApiModelProperty("最新时间")
    private Date modifiedTime;

    public void setCount(Integer count,PrivateLetterVo privateLetterVo) {
        if (count > 0){
            privateLetterVo.setReadStatus(ReadStatus.UNREAD);
        }else {
            privateLetterVo.setReadStatus(ReadStatus.READ);
        }
        privateLetterVo.setCount(count);
    }

    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = PictureUtils.addPrefix(avatarUrl);
    }

    public void setPath(String path) {
        this.path = PictureUtils.addPrefix(path);
    }
}
